package edu.xlh.travel.controller.admin;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import edu.xlh.travel.common.Result;
import edu.xlh.travel.pojo.OnlineUserInfo;
import edu.xlh.travel.pojo.SysLog;
import edu.xlh.travel.service.SysLogService;
import edu.xlh.travel.syslog.annontion.Log;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import springfox.documentation.spring.web.json.Json;

import javax.servlet.http.HttpSession;
import java.util.HashMap;
import java.util.List;

@Controller
@RequestMapping("/sysLog")
public class SysLogController {
    @Autowired
    private SysLogService sysLogService;

    /*
     * to sysLogInfoList page
     * */
    @Log("跳转系统日志列表")
    @RequestMapping("/sysLogInfoList")
    public String sysLogList() {
        return "admin/systemMonitoring/sysLogInfoList";
    }

    @Log("查询所有 的系统日志信息")
    @RequestMapping("/findAllSysLogInfo")
    @ResponseBody
    public Result findAllSysLogInfo(int page, int limit , HttpSession session) {
        return sysLogService.findAllSysLogInfo(page , limit , session);
    }

    /*
     * query sysLog by condition
     * */
    @Log("条件模糊查询系统日志")
    @RequestMapping("/QuerySysLogByCondition")
    @ResponseBody
    public Result  QuerySysLogByCondition(Integer page, Integer limit , SysLog sysLog , HttpSession session) {
        return sysLogService.QuerySysLogByCondition(page , limit , sysLog , session);
    }

    /*
    *
    * batch delete
    *  */
    @Log("批量删除系统日志")
    @RequestMapping("/batchDelete")
    @ResponseBody
    public Result batchDelete(@RequestBody JSONArray jsonArray , HttpSession session) {
        return sysLogService.batchDelete(jsonArray ,session);
    }

    /*
     * delete sysLog by id
     * */
    @Log("根据id删除系统日志")
    @RequestMapping("/deleteById/{id}")
    @ResponseBody
    public Result deleteById(@PathVariable("id") String id , @RequestBody HashMap hashMap , HttpSession session) {
        return sysLogService.deleteById(id , hashMap , session);
    }
}
